package com.leetcode.array_matrix;

/**
 * @author Dennis Li
 * @date 2020/7/31 10:19
 */
public class ReplaceElements_1299 {

    public int[] replaceElements(int[] arr) {
        int len = arr.length;
        int max = -1;
        for (int i = len - 1; i >= 0; i--) {
            int temp = arr[i];
            arr[i] = max;
            max = Math.max(temp, max);
        }
        return arr;
    }

}
